<template>
  <div class="search-bar">
    <div class="select-item">
      <div class="item start">
        <div class="name">住</div>
        <div class="date">{{ startDateStr }}</div>
      </div>
      <div class="item end">
        <div class="name">离</div>
        <div class="date">{{ endDateStr }}</div>
      </div>
    </div>
    <div class="content">
      <div class="keyword">关键字/位置/民宿</div>
    </div>
    <div class="right">
      <i class="search-icon"></i>
    </div>
  </div>
</template>

<script setup>
 import useMainStore from '@/store/modules/main';
 import {formatMonthDay} from '../../utils/format_date'
 import { computed } from '@vue/runtime-core';
 import { storeToRefs } from 'pinia'

 const mainStore =  useMainStore()
 const { startDate, endDate } = storeToRefs(mainStore)
 const startDateStr = computed(()=> formatMonthDay(startDate.value, "MM.DD"))
 const endDateStr = computed(()=> formatMonthDay(endDate.value, "MM.DD"))
</script>

<style lang="less" scoped>
 .search-bar {
   display: flex;
   flex-direction: row;
   justify-content: space-between;
   height: 45px;
   align-items: center;
   background-color: #f2f4f6;
   color: #999;
   .select-item {
     .item{
       display: flex;
       flex-direction: row;
       .name {
         color: #999;
       }
       .date {
         margin-left: 5px;
         color: #333;
       }
     }
   }
   .content {
     padding: 0 6px;
     flex: 1;
     .keyword {
       max-width: 155px;
       color: #999;
     }
   }
   .right {
     .search-icon {
       width: 24px;
       height: 24px;
       display: inline-block;

       background-image: url(../../assets/img/home/home-sprite.png);
       background-position: -29px -151px;
       background-size: 207px 192px ;
     }
   }
 }
</style>
